package two_shang._9_28;

public class Student {
    private String name;

    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age < 0) {
            System.out.println("设置的年龄不合法");
        } else {
            this.age = age;
            System.out.println(age);
        }
    }

    public void speak() {
        System.out.println("我是" + name + "我" + age + "岁");
    }

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Student(String name) {
        this.name = name;
    }
}
